<?php
class Websis_Filter_StringPad implements Zend_Filter_Interface
{
    protected $_qtd     = 10;
    protected $_string  = '_';
    protected $_align   = 'R';

    protected $_arAlign = array(
        'L' => STR_PAD_LEFT,
        'R' => STR_PAD_RIGHT,
        'B' => STR_PAD_BOTH
    );

    public function __construct($options = array())
    {
        if(array_key_exists('qtd', $options)){
            $this->_qtd = $options['qtd'];
        }
        if(array_key_exists('string', $options)){
            $this->_string = $options['string'];
        }
        if(array_key_exists('align', $options)){
            $this->_align = $options['align'];
        }
    }

    public function filter($value)
    {
        return str_pad($value, $this->_qtd, $this->_string, $this->_arAlign[$this->_align]);
    }

}